/**
 * Copyright (C) 2019 Bonitasoft S.A.
 * Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301, USA.
 **/
package org.bonitasoft.platform.configuration.model;

import org.assertj.core.api.AbstractAssert;
import org.assertj.core.api.Assertions;
import org.assertj.core.util.Objects;

/**
 * {@link BonitaConfiguration} specific assertions - Generated by CustomAssertionGenerator.
 */
public class BonitaConfigurationAssert extends AbstractAssert<BonitaConfigurationAssert, BonitaConfiguration> {

    /**
     * Creates a new <code>{@link BonitaConfigurationAssert}</code> to make assertions on actual BonitaConfiguration.
     *
     * @param actual the BonitaConfiguration we want to make assertions on.
     */
    public BonitaConfigurationAssert(BonitaConfiguration actual) {
        super(actual, BonitaConfigurationAssert.class);
    }

    /**
     * An entry point for BonitaConfigurationAssert to follow AssertJ standard <code>assertThat()</code> statements.<br>
     * With a static import, one can write directly: <code>assertThat(myBonitaConfiguration)</code> and get specific
     * assertion with code completion.
     *
     * @param actual the BonitaConfiguration we want to make assertions on.
     * @return a new <code>{@link BonitaConfigurationAssert}</code>
     */
    public static BonitaConfigurationAssert assertThat(BonitaConfiguration actual) {
        return new BonitaConfigurationAssert(actual);
    }

    /**
     * Verifies that the actual BonitaConfiguration's resourceContent contains the given byte elements.
     *
     * @param resourceContent the given elements that should be contained in actual BonitaConfiguration's
     *        resourceContent.
     * @return this assertion object.
     * @throws AssertionError if the actual BonitaConfiguration's resourceContent does not contain all given byte
     *         elements.
     */
    public BonitaConfigurationAssert hasResourceContent(byte... resourceContent) {
        // check that actual BonitaConfiguration we want to make assertions on is not null.
        isNotNull();

        // check that given byte varargs is not null.
        if (resourceContent == null)
            failWithMessage("Expecting resourceContent parameter not to be null.");

        // check with standard error message (use overridingErrorMessage before contains to set your own message).
        Assertions.assertThat(actual.getResourceContent()).contains(resourceContent);

        // return the current assertion for method chaining
        return this;
    }

    /**
     * Verifies that the actual BonitaConfiguration's resourceContent contains <b>only<b> the given byte elements and
     * nothing else in whatever order.
     *
     * @param resourceContent the given elements that should be contained in actual BonitaConfiguration's
     *        resourceContent.
     * @return this assertion object.
     * @throws AssertionError if the actual BonitaConfiguration's resourceContent does not contain all given byte
     *         elements and nothing else.
     */
    public BonitaConfigurationAssert hasOnlyResourceContent(byte... resourceContent) {
        // check that actual BonitaConfiguration we want to make assertions on is not null.
        isNotNull();

        // check that given byte varargs is not null.
        if (resourceContent == null)
            failWithMessage("Expecting resourceContent parameter not to be null.");

        // check with standard error message (use overridingErrorMessage before contains to set your own message).
        Assertions.assertThat(actual.getResourceContent()).containsOnly(resourceContent);

        // return the current assertion for method chaining
        return this;
    }

    /**
     * Verifies that the actual BonitaConfiguration's resourceContent does not contain the given byte elements.
     *
     * @param resourceContent the given elements that should not be in actual BonitaConfiguration's resourceContent.
     * @return this assertion object.
     * @throws AssertionError if the actual BonitaConfiguration's resourceContent contains any given byte elements.
     */
    public BonitaConfigurationAssert doesNotHaveResourceContent(byte... resourceContent) {
        // check that actual BonitaConfiguration we want to make assertions on is not null.
        isNotNull();

        // check that given byte varargs is not null.
        if (resourceContent == null)
            failWithMessage("Expecting resourceContent parameter not to be null.");

        // check with standard error message (use overridingErrorMessage before contains to set your own message).
        Assertions.assertThat(actual.getResourceContent()).doesNotContain(resourceContent);

        // return the current assertion for method chaining
        return this;
    }

    /**
     * Verifies that the actual BonitaConfiguration has no resourceContent.
     *
     * @return this assertion object.
     * @throws AssertionError if the actual BonitaConfiguration's resourceContent is not empty.
     */
    public BonitaConfigurationAssert hasNoResourceContent() {
        // check that actual BonitaConfiguration we want to make assertions on is not null.
        isNotNull();

        // we override the default error message with a more explicit one
        String assertjErrorMessage = "\nExpecting :\n  <%s>\nnot to have resourceContent but had :\n  <%s>";

        // check
        if (actual.getResourceContent().length > 0) {
            failWithMessage(assertjErrorMessage, actual, java.util.Arrays.toString(actual.getResourceContent()));
        }

        // return the current assertion for method chaining
        return this;
    }

    /**
     * Verifies that the actual BonitaConfiguration's resourceName is equal to the given one.
     *
     * @param resourceName the given resourceName to compare the actual BonitaConfiguration's resourceName to.
     * @return this assertion object.
     * @throws AssertionError - if the actual BonitaConfiguration's resourceName is not equal to the given one.
     */
    public BonitaConfigurationAssert hasResourceName(String resourceName) {
        // check that actual BonitaConfiguration we want to make assertions on is not null.
        isNotNull();

        // overrides the default error message with a more explicit one
        String assertjErrorMessage = "\nExpecting resourceName of:\n  <%s>\nto be:\n  <%s>\nbut was:\n  <%s>";

        // null safe check
        String actualResourceName = actual.getResourceName();
        if (!Objects.areEqual(actualResourceName, resourceName)) {
            failWithMessage(assertjErrorMessage, actual, resourceName, actualResourceName);
        }

        // return the current assertion for method chaining
        return this;
    }

}
